﻿@{
    ViewData["Title"] = "Edit";
    List<Ace.Entity.Wiki.Sort> ListSort = ViewBag.ListSort as List<Ace.Entity.Wiki.Sort>;
    List<Ace.Entity.Wiki.District> ListDistrict = ViewBag.ListDistrict as List<Ace.Entity.Wiki.District>;
}
 

<div class="container">
    <div class="row">
        <form class="form-horizontal col-md-12"  method="post" action="/Wiki/Shop/Add">
            <fieldset>
                <div id="legend" class="">
                    <legend class="">店铺编辑</legend>
                </div>


                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon1">店铺标题</span>
                        <input type="text" class="form-control" value="" id="ShopName" name="ShopName" aria-describedby="basic-addon1">
                    </div>
                </div>



                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon2">品牌名称</span>
                        <select class="form-control" id="BrandID" name="BrandID">
                            @foreach (var item in ListSort)
                            {
                                <option value="@item.Id">@item.Title</option>
                            }
                        </select>
                    </div>
                </div>


                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">店铺电话</span>
                        <input type="text" class="form-control" value="" id="ShopTel" name="ShopTel" aria-describedby="basic-addon3">
                    </div>
                </div>

                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">所在区域</span>
                        <select type="text" class="form-control" id="ProvinceID" name="ProvinceID" style="width:30%">
                            @foreach (var item in ListDistrict)
                            {
                                <option value="@item.ID">@item.Name</option>
                            }
                        </select>
                        <select type="text" class="form-control" value="" id="CityID" name="CityID" aria-describedby="basic-addon3" style="width:30%"></select>
                        <select type="text" class="form-control" value="" id="PartID" name="PartID" aria-describedby="basic-addon3" style="width:40%"></select>
                    </div>
                </div>

                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">店铺地址</span>
                        <input type="text" class="form-control" value="" id="ShopAddress" name="ShopAddress" aria-describedby="basic-addon3">
                    </div>
                </div>

                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">店铺经度</span>
                        <input type="text" class="form-control" value="" id="GPS_X" name="GPS_X" aria-describedby="basic-addon3">
                    </div>
                </div>

                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">店铺纬度</span>
                        <input type="text" class="form-control" value="" id="GPS_Y" name="GPS_Y" aria-describedby="basic-addon3">
                    </div>
                </div>

                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">店铺门面</span>
                        <input type="text" class="form-control" value="" id="ShopUrl" name="ShopUrl" aria-describedby="basic-addon3">
                    </div>
                </div>

                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">营业执照</span>
                        <input type="text" class="form-control" value="" id="LicenseUrl" name="LicenseUrl" aria-describedby="basic-addon3">
                    </div>
                </div>

                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon3">店铺简介</span>
                        <input type="text" class="form-control" value="" id="Summary" name="Summary" aria-describedby="basic-addon3">
                    </div>
                </div>

                <div class="form-group">
                    <input type="submit" value="提交" class="btn btn-primary" />
                </div>

            </fieldset>
    </form>

</div>
</div>
 <script type="text/javascript">
     $(function () { 

         $("#ProvinceID").change(function () {
             var s = $("#ProvinceID").val();
             GetChildDistrict(s,"CityID");
         });

         $("#CityID").change(function () {
             var s = $("#CityID").val();
             GetChildDistrict(s, "PartID");
         });

     })

     function GetChildDistrict(pid,obj)
     {
         $ace.get("/Wiki/District/GetList", { Pid: pid }, function (result) {
             bindPosts(obj,result.Data, true,"");
         });
     }

     function bindPosts(obj,data, rebind, selectedValues) {
         var $ele = $('#' + obj);
         if (rebind) {
             $ele.empty();
         }
         if (data) {
             var s = "";
             jQuery(data).each(function (i, item) {
                 s += "<option value='" + item["ID"] + "'>" + item["Name"] + "</option>";
             });
             $ele.html(s);
         }

         if (selectedValues) {
             $ele.val(selectedValues); 
         }
     }

 </script>